package lab;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class sha256 {
    public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        //MD5
        //sha256
        MessageDigest messageDigest=MessageDigest.getInstance("SHA-256");
        String s="你好世界";
        byte[] buffer=s.getBytes("UTF-8");
            messageDigest.update(buffer);
            byte[] result=messageDigest.digest();
            for (byte b:result){
                System.out.printf("%02x",b);
            }
    }
}
